﻿using System.IO;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System;

using System.Collections.Generic;
using System.Text;

namespace CEProxy
{
    class NativeMethods
    {
        internal const int HWND_BROADCAST = 0xffff;
        internal const int WM_WININICHANGE = 0x001A;

        [DllImport("coredll.dll")]
        private static extern int SendMessage(IntPtr hWnd, uint msg, int wParam, int lParam);

        internal static void SetDeskWallpaper(string devicePath)
        {
            // Copy wallpaper file to windows directory
            //File.Copy(@"\My Documents\My Pictures\ImageFileName.jpg", @"\Windows\stwater_240_240.jpg", true);

            // Update registry
            Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Today", "Wall", devicePath);
        }

        internal static void NotifyChange()
        {
            // Send message to refresh today screen
            SendMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);            
        }
    }
}
